package com.markerhub.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.markerhub.entity.SysCourseLocation;
import com.markerhub.entity.SysLocation;
import com.markerhub.mapper.SysLocationMapper;
import com.markerhub.service.SysLocationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.io.Serializable;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wang
 * @since 2022-03-31
 */
@Service
public class SysLocationServiceImpl extends ServiceImpl<SysLocationMapper, SysLocation> implements SysLocationService {

    @Override
    public Serializable getIdByLocation(String courseLocation) {
        return getOne(new QueryWrapper<SysLocation>().eq("course_location", courseLocation));
    }

    @Override
    public String getLocationById (Long id){
        return getOne(new QueryWrapper<SysLocation>().eq("id",id)).getCourseLocation();
    }

    @Override
    public SysLocation getObject(String courseLocation) {
        return getOne(new QueryWrapper<SysLocation>().eq("course_location", courseLocation));
    }

    @Override
    public Long getByLocation(String location) {
        return getOne(new QueryWrapper<SysLocation>().eq("course_location", location)).getId();

    }

    @Override
    public String getLocayionByCourseId(Long id) {

        return getOne(new QueryWrapper<SysLocation>().eq("id", id)).getCourseLocation();
    }
}
